package com.itheima.mapper;

import com.itheima.domain.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface ProductMapper {
    /**
     * 搜索商品信息
     * @param searchString 搜索条件
     * @return 搜索结果
     */
    @Select("select * from j_product where title like concat('%',#{searchString},'%')")
    List<Product> search(String searchString);

    /**
     * 添加商品信息
     * @param product 商品对象
     */
    @Insert("insert into j_product values(null,#{title},#{price},#{commit},#{shop},#{img},#{href},#{mark})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void add(Product product);
    @Select("select * from j_product")
    List<Product> findAll();
}
